package com.eastfair.imaster.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 公司审核用户表
 * </p>
 *
 * @author ligang
 * @date 2021-08-31
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CheckEmployeeStatusEnum", description = "状态#{normal:正常;checking:审核中;check_succ:审核成功;check_fail:审核失败-枚举")
public enum CheckEmployeeStatusEnum implements BaseEnum {

    /**
     * NORMAL="正常"
     */
    NORMAL("正常"),
    /**
     * CHECKING="审核中"
     */
    CHECKING("审核中"),
    /**
     * CHECK_SUCC="审核成功"
     */
    CHECK_SUCC("审核成功"),
    /**
     * CHECK_FAIL="审核失败"
     */
    CHECK_FAIL("审核失败"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CheckEmployeeStatusEnum match(String val, CheckEmployeeStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CheckEmployeeStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CheckEmployeeStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "NORMAL,CHECKING,CHECK_SUCC,CHECK_FAIL", example = "NORMAL")
    public String getCode() {
        return this.name();
    }

}
